Configure Git Bash shell profiles during Windows install#522
Open
Configure Git Bash shell profiles during Windows install#522
Conversation
Git Bash (MSYS2/MinGW) prepends /mingw64/bin to PATH during shell initialization, which shadows the git-ai shim even when the Windows PATH has been correctly configured. Fix this by detecting Git for Windows installations and writing an export PATH line to ~/.bashrc or ~/.bash_profile, mirroring what install.sh already does for Unix shells. Closes #517 Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
No AI authorship found for these commits. Please install git-ai to start tracking AI generated code in your commits. |
|
|
Member
Author
|
review devin feedback |
PowerShell 5.1's Add-Content -Encoding UTF8 writes a UTF-8 BOM that causes 'command not found' errors in bash. Use .NET's UTF8Encoding(false) + AppendAllText instead to avoid the BOM. Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
Member
Author
|
review devin feedback |
On 32-bit Windows, env vars like ProgramFiles(x86) may be null, causing Join-Path to throw under StrictMode before the null-guard in the loop could run. Build the array conditionally instead. Co-Authored-By: Sasha Varlamov <sasha@sashavarlamov.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Configure Git Bash shell profiles during Windows install
Summary
Fixes #517. Git Bash (MSYS2/MinGW) prepends
/mingw64/bintoPATHduring its own shell initialization, which shadows thegit-aishim even when the Windows PATH has been correctly set bySet-PathPrependBeforeGit. This adds a new section toinstall.ps1that writesexport PATH="$HOME/.git-ai/bin:$PATH"into the user's~/.bashrcor~/.bash_profile, mirroring whatinstall.shalready does for Unix shells.The new block:
Program Files,Program Files (x86),LocalAppData\Programs), guarding each path against null env vars.bashrcor.bash_profile(or creates.bashrcif neither exists).git-ai/binmarker to avoid duplicate entries[System.IO.File]::AppendAllTextwithUTF8Encoding($false))Updates since last revision
Add-Content -Encoding UTF8with[System.IO.File]::AppendAllText()usingUTF8Encoding($false)to avoid writing a BOM that would causecommand not founderrors in bash on PowerShell 5.1.Join-Pathcalls for Git Bash detection paths are now guarded withifchecks so a nullProgramFiles(x86)(e.g. on 32-bit Windows) doesn't abort the entire Git Bash config block underSet-StrictMode.Review & Testing Checklist for Human
which gitresolves to~/.git-ai/bin/git(not/mingw64/bin/git)UTF8Encoding($false)+AppendAllText, but confirm the written file has no BOM bytes (EF BB BF) at the start, especially when.bashrcis newly created (no pre-existing file).bashrc.bashrcand the export line is correct. Consider whether creating.bashrcwhen a user has never used Git Bash is desirable, or if this should only append to existing filesNotes
%USERPROFILE%\.bashrc/.bash_profile).